<template>
  <div class="pagination">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageData.page"
      :page-sizes="[5, 10, 20, 30, 40, 50, 100, 150, 200, 300, 400, 500, 600, 800, 1000]"
      :page-size="pageData.size"
      :layout="layout"
      :total="pageData.totalRows">
    </el-pagination>
  </div>
</template>

<script>

export default {
  name: 'sys-pagination',
  props: {
    pageData: {
      type: Object
    },
    layout: {
      type: String,
      default: 'total, sizes, prev, pager, next'
    }
  },
  data () {
    return {
    }
  },
  mounted () {
  },
  methods: {
    handleCurrentChange (val) {
      this.pageData.page = val
      this.$emit('refreshPageData')
    },
    handleSizeChange (val) {
      this.pageData.size = val
      this.pageData.page = 1 // 修改成第一页
      this.$emit('refreshPageData')
    }
  }
}
</script>

<style lang="scss">
.pagination {
  text-align: right;
  margin-top: 5px;
}
</style>
